home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 8
/
FM Towns Free Software Collection 8.iso
/
t_os
/
dc14
/
src
/
main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-06-01
|
3KB
|
141 lines
/****************************************************
Document Chain version 1.4
ALGO [TOOLS no.02]
1994.02.14
******************************************************/
#include<stdio.h>
#include<string.h>
#include<dos.h>
#include<direct.h>
#include<ctype.h>
#include<stdlib.h>
#include"list.h"
#include"chain.h"
#define TRUE (-1)
#define FALSE 0
#define VERSION "ver 1.4"
#define DATE "1994.02.08"
LIST head;
PARA infile,outfile;
int size=65535; /* ファイルのトータルサイズ */
int cnt=0; /* ファイルカウンター */
FILE *ofp; /* 出力用のファイルポインター */
char file[14]; /* ファイルネーム用バッファ */
void CmdAnalyse(char *st,PARA *pa); /* 作ったあとで _splitpathを使えば
いいことを知った... */
void msg(void);
void usage(void);
void main(int argc,char *argv[])
{
int i,n,dmy;
char in_flag=FALSE,*p=NULL;
if(argc==1){
usage();exit(0);
}
for(i=1;i<argc;i++){
if((*p=*argv[i])=='-'){
*p=*(++argv[i]);
switch(toupper(*p)){
case 'D': /* 只今整備中(^^;) */
break;
case 'S': size=atoi(++argv[i])*1024;
if(size<512 || size>1024*1024){
fprintf(stderr,"サイズの指定に誤りがあります\n");
exit(1);
}
break;
}
}else{
if(in_flag==FALSE){
CmdAnalyse(argv[i],&infile);
in_flag=TRUE;
}else{
CmdAnalyse(argv[i],&outfile);
}
}
}
msg();
printf("File size %05d byte.\n",size);
printf("Make target file list");
n=MakeList(infile);
printf("(%03d targets).\n",n);
printf("Line count.\n");
for(i=0;i<n;i++)printf(".");
printf("\r");
LineCount();
printf("\n");
_dos_setdrive(outfile.drive,(unsigned int *)&dmy);
if(outfile.path[0] != '\0')
if (_chdir(outfile.path)==ERR){
printf("ディレクトリの指定が違います.");
exit(1);
}
while((cnt=SetFlag(size))!=0){
WriteOpenName(file);
if((ofp=fopen(file,"w"))==NULL){
fprintf(stderr,"Fine open error.'%s'",file);
exit(1);
}
printf("Create '%s' \n",file);
MakeIndex(cnt);
Chain(cnt);
fclose(ofp);
ClearFlag();
}
ClearFlag();
return;
}
void CmdAnalyse(char *st,PARA *pa)
{
char *p;
unsigned int drv;
if((p=strchr(st,':'))!=NULL) {
pa->drive=toupper(*(p-1))-'A'+1;
st=p+1;
}else{
_dos_getdrive(&drv);
pa->drive=drv;
}
if((p=strrchr(st,'\\'))!=NULL){
if(p==st){
strcpy(pa->path,"\\\0");
st++;
}else{
*p='\0';
strcpy(pa->path,st);
st=p+1;
}
}
strcpy(pa->file,st);
}
void msg(void)
{
printf("<<Document Chain %s>> [TOOLS NO.02] ALGO\n",VERSION);
}
void usage(void)
{
msg();
printf(" usage: run386 dc <option> <target file> <output file>\n");
printf(" option ... -sxx 一つの分割ファイルのファイルの大きさ\n");
printf(" 単位はkb。省略時は64kb固定。\n");
}